function toggleLock() {
	if ($('lockimage').src.slice($('lockimage').src.length-12) == "unlocked.gif") {
		$('lockimage').src = $('lockimage').src.slice(0, $('lockimage').src.length-12)+"locked.gif";
	} else {
		$('lockimage').src = $('lockimage').src.slice(0, $('lockimage').src.length-10)+"unlocked.gif";
	}
}

function lockDiscussion() {
	$('moderatoract').value = 'lock';
	$('moderation').submit();
}

function toggleSticky() {
	if ($('stickyimage').src.slice($('stickyimage').src.length-12) == "unsticky.gif") {
		$('stickyimage').src = $('stickyimage').src.slice(0, $('stickyimage').src.length-12)+"sticky.gif";
	} else {
		$('stickyimage').src = $('stickyimage').src.slice(0, $('stickyimage').src.length-10)+"unsticky.gif";
	}
}

function stickyDiscussion() {
	$('moderatoract').value = 'sticky';
	$('moderation').submit();
}

function moderatorEnhance() {
	Element.show('modlinks');
	Element.hide('moderation');
	Event.observe($('lock'), 'mouseover', toggleLock, false);
	Event.observe($('lock'), 'mouseout', toggleLock, false);
	Event.observe($('lock'), 'click', lockDiscussion, false);
	
	Event.observe($('sticky'), 'mouseover', toggleSticky, false);
	Event.observe($('sticky'), 'mouseout', toggleSticky, false);
	Event.observe($('sticky'), 'click', stickyDiscussion, false);
}

function commentEnhance() {
	var e = document.getElementsByClassName('quotecomment');
	for (i=0;i<e.length;i++) {
		e[i].href='#addcomment';
		e[i].onclick=quoteComment;
	}
}

function quoteComment(event) {
	var element = Event.element(event);
	var childs = element.parentNode.parentNode.childNodes;
	for (i=0;i<childs.length;i++) {
		if (childs[i].className == "commentinfo") {
			for (j=0;j<childs[i].childNodes.length;j++) {
				if (childs[i].childNodes[j].className == "commentuser") {
					var cite = childs[i].childNodes[j].innerHTML;
				}
			}
		} else if (childs[i].className == "commentcontent") {
			for (j=0;j<childs[i].childNodes.length;j++) {
				if (childs[i].childNodes[j].className == "commentmain") {
					var comment = childs[i].childNodes[j].innerHTML;
				}
			}
		}
	}
	
	tinyMCE.setContent(tinyMCE.getContent()+'<blockquote><p><strong><cite>'+cite+' said:</cite></strong></p>'+comment+'</blockquote><p> </p>');
}

Event.observe(window, 'load', moderatorEnhance, false);
Event.observe(window, 'load', commentEnhance, false);